/**
 * 项目名称: Topic_404.cpp
 * 项目路径: study/DataStructure/LeetCode/树/简单
 * 编辑时间: 2024年08月08日08时09分32秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;

    TreeNode() : val(0), left(nullptr), right(nullptr) {}

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    int cnt = 0;
    void pre(TreeNode*root,int flag){
        if(root->left){
            pre(root->left,1);
        }
        if(root->right){
            pre(root->right,0);
        }
        if(flag == 1 && !root->left && !root->right)cnt+=root->val;
    }
    int sumOfLeftLeaves(TreeNode* root) {
        pre(root,0);
        return cnt;
    }
};

int main() {

    return 0;
}
